﻿#pragma once
#ifndef MAINWIDGET_H
#define MAINWIDGET_H

#include <QWidget>
#include "chatdb.h"
#include <QMouseEvent>
#include <QGraphicsDropShadowEffect>
#include <QTreeWidget>
#include <QTreeWidgetItem>
#include "chatwidget.h"
#include <QList>
#include "MyPDU.h"
#include "chatsocket.h"

namespace Ui {
class MainWidget;
}

class MainWidget : public QWidget
{
    Q_OBJECT
public:
    ~MainWidget();
    static MainWidget* getInstance();
    void init(const QString& id);
    void loadFriendAndLoadGroup(const QList<UserInfo>& uinfo,const QList<groupinfo>& ginfo);
    void changeUserStatus(QString id,bool status);
//    void addToFriendList(const UserInfo& userInfo);
    bool queryIsFriend(QString id);//查询被加好友者是否是你的好友
private:
    MainWidget(QWidget *parent = nullptr);
    void setShadow();
    void loadImg();//加载图标
protected:
    void mousePressEvent(QMouseEvent *event);//鼠标点击
    void mouseMoveEvent(QMouseEvent *event);//鼠标移动
    void mouseReleaseEvent(QMouseEvent *event);//鼠标释放
private slots:
    void on_btn_close_clicked();

    void on_btn_min_clicked();

    void on_treeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column);

    void on_tool_addfriend_clicked();

    void on_lineEdit_textChanged(const QString &arg1);

private:
    Ui::MainWidget *ui;
    static MainWidget* m_pMain;
    bool isPressedWidget;//isPressedWidget控制窗口移动
    QPoint last_point;//记录窗口位置和全局位置
    QTreeWidget* m_pTreeWidget;
public:

};

#endif // MAINWIDGET_H
